﻿using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;
using System.Collections.Generic;
using System.Collections.ObjectModel;

namespace DotNTech.Converters
{
    public class LargeText : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value != null)
            {
                if (value.ToString().Length > 2000)
                {
                    if (parameter.ToString() == "first")
                    {
                        int indx = value.ToString().Substring(0, 2000).LastIndexOf("\n");
                        return value.ToString().Substring(0, indx);
                    }
                    else
                    {
                        int indx = value.ToString().Substring(0, 2000).LastIndexOf("\n");
                        return value.ToString().Substring(indx+1);
                    }
                }
                else
                {
                    return parameter.ToString() == "first" ? value : string.Empty;
                }
            }
            return value;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }


    //public class bgcolor : IValueConverter
    //{
    //    static 
    //    public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
    //    {
    //        return value;
    //    }

    //    public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
    //    {
    //        throw new NotImplementedException();
    //    }
    //}

    }
